package controllers

import (
	"github.com/astaxie/beego"
	lsql "jujiu/data/persist/mysql"
	"log"
)

type RomVerisonController struct {
	beego.Controller
}

func (r *RomVerisonController) DeleteRomVersion() {
	romVer := r.GetString("romVer")
	if romVer == "" {
		log.Println("获取参数错误！")
		r.Ctx.WriteString("参数为空")
		return
	}

	clinet := lsql.DataSourceClientMap["cn_real"]
	mapper := lsql.NewRomVersionMapper(&clinet)
	version := mapper.SelectByVersion(romVer)
	if version == nil {
		r.Ctx.WriteString("固件版本不存在")
		return
	}
	byVersion := mapper.DeleteByVersion(romVer)
	if byVersion < 1 {
		r.Ctx.WriteString("删除失败")
		return
	}
	r.Ctx.WriteString("删除成功")
	return

}
